﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>ComObjError - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The ComObjError function enables or disables notification of COM errors." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>ComObjError</h1>

<p>Enables or disables notification of COM errors.</p>

<pre class="Syntax">IsEnabled := <span class="func">ComObjError</span>(<span class="optional">Enable</span>)</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>Enable</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#boolean">整数(布尔值)</a></p>
    <p>Specify 1 (true) to enable notification of COM errors or 0 (false) to disable it. This parameter can be omitted to retrieve the current setting without making any changes, 例如: <code>IsEnabled := ComObjError()</code>.</p>
  </dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#boolean">整数(布尔值)</a></p>
<p>This function returns the setting which was in effect before the function was called.</p>

<h2 id="Remarks">备注</h2>
<p>Notification of COM errors is enabled by default.</p>
<p>COM errors may be raised by <a href="ComObjCreate.htm">ComObjCreate</a>, <a href="ComObjGet.htm">ComObjGet</a>, <a href="ComObjActive.htm">ComObjActive</a>, <a href="ComObjConnect.htm">ComObjConnect</a>, <a href="ComObjFlags.htm">ComObjFlags</a>, <a href="ComObjValue.htm">ComObjValue</a>, <a href="ComObjQuery.htm">ComObjQuery</a> (if an invalid pointer is detected) or by a method or property of a COM object. Raising a COM error causes one of the following outcomes:</p>
<table class="info" id="factors">
  <tr><th>Setting</th><th>Outcome</th></tr>
  <tr>
    <td>0 (disabled)</td>
    <td>The function, method or property returns a default value (typically an empty string), without showing an error dialog.</td>
  </tr>
  <tr>
    <td>1 (enabled)</td>
    <td>
      <p>If there is an active <a href="Try.htm">Try</a> block, an exception is thrown. Otherwise:</p>
      <p>An error dialog is shown, giving the user the option to continue the script. If the user chooses "Yes", the function, method or property returns a default value (typically an empty string) and the script continues. Otherwise, the script exits.</p>
    </td>
  </tr>
</table>
<p>After accessing a COM object, <a href="../Variables.htm#LastError">A_LastError</a> contains the HRESULT code returned by the COM object's <a href="http://msdn.microsoft.com/en-us/library/ms221479.aspx">IDispatch::Invoke</a> function. The script may consult A_LastError within a <a href="Catch.htm">Catch</a> block or after the method or property returns, provided that <code>ComObjError(false)</code> has been used or the user did not choose to exit the script.</p>

<h2 id="Related">相关</h2>
<p><a href="ComObjCreate.htm">ComObjCreate</a>, <a href="ComObjGet.htm">ComObjGet</a>, <a href="ComObjActive.htm">ComObjActive</a>, <a href="ComObjConnect.htm">ComObjConnect</a>, <a href="ComObjQuery.htm">ComObjQuery</a></p>

</body>
</html>